package com.wmlive.hhvideo.heihei.personal.activity;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.util.SparseArrayCompat;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wmlive.hhvideo.common.base.DcBaseActivity;
import com.wmlive.hhvideo.common.base.DcBaseFragment;
import com.wmlive.hhvideo.common.navigator.Navigator;
import com.wmlive.hhvideo.heihei.beans.login.UserInfo;
import com.wmlive.hhvideo.heihei.beans.main.ShareInfo;
import com.wmlive.hhvideo.heihei.beans.personal.ReportType;
import com.wmlive.hhvideo.heihei.beans.personal.ReportTypeResponse;
import com.wmlive.hhvideo.heihei.beans.personal.UserHomeData;
import com.wmlive.hhvideo.heihei.beans.personal.UserHomeRelation;
import com.wmlive.hhvideo.heihei.beans.splash.InitCatchData;
import com.wmlive.hhvideo.heihei.channel.ShareSdkUtils;
import com.wmlive.hhvideo.heihei.login.AccountUtil;
import com.wmlive.hhvideo.heihei.personal.PersonalFragment;
import com.wmlive.hhvideo.heihei.personal.RecyclerScrollListener;
import com.wmlive.hhvideo.heihei.personal.adapter.MyFragmentPagerAdapter;
import com.wmlive.hhvideo.heihei.personal.fragment.PersonalLoveFragment;
import com.wmlive.hhvideo.heihei.personal.fragment.PersonalProductFragment;
import com.wmlive.hhvideo.heihei.personal.presenter.OtherHomePresenter;
import com.wmlive.hhvideo.heihei.personal.view.IOtherHomeView;
import com.wmlive.hhvideo.utils.DensityUtils;
import com.wmlive.hhvideo.utils.DeviceUtils;
import com.wmlive.hhvideo.utils.MyClickListener;
import com.wmlive.hhvideo.utils.PopupWindowUtils;
import com.wmlive.hhvideo.utils.ScreenUtil;
import com.wmlive.hhvideo.utils.ToastUtil;
import com.wmlive.hhvideo.utils.imageloader.GlideLoader;
import com.wmlive.hhvideo.widget.dialog.CustomDialog;
import com.wmlive.hhvideo.widget.dialog.PopActionSheetNoTitle;
import com.wmlive.hhvideo.widget.dialog.PopReportContentActionSheet;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.wmlive.hhvideo.R;
import cn.wmlive.hhvideo.rxbuslib.RxBus2;

/**
 * Created by XueFei on 2017/6/3.
 * <p>
 * 他人主页--个人主页
 */

public class PersonalHomeActivity extends DcBaseActivity implements IOtherHomeView, ViewPager.OnPageChangeListener, RecyclerScrollListener, PlatformActionListener {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_other_home_more)
    ImageView ivOtherHomeMore;
    @BindView(R.id.ll_other_home_product)
    LinearLayout llOtherHomeProduct;
    @BindView(R.id.tv_other_home_product_count)
    TextView tvOtherHomeProductCount;
    @BindView(R.id.ll_other_home_love)
    LinearLayout llOtherHomeLove;
    @BindView(R.id.tv_other_home_love_count)
    TextView tvOtherHomeLoveCount;
    @BindView(R.id.vp_other_home_fragments)
    ViewPager vpOtherHomeFragments;
    @BindView(R.id.iv_other_home_header)
    ImageView ivOtherHomeHeader;
    @BindView(R.id.tv_other_home_name)
    TextView tvOtherHomeName;
    @BindView(R.id.ll_other_home_add)
    LinearLayout ivOtherHomeAdd;
    @BindView(R.id.iv_other_home_focus_state)
    ImageView ivOtherHomeFocusState;
    @BindView(R.id.tv_other_home_focus_state)
    TextView tvOtherHomeFocusState;
    @BindView(R.id.tv_other_home_info)
    TextView tvOtherHomeInfo;
    @BindView(R.id.tv_personal_id)
    TextView tvPersonalId;
    @BindView(R.id.tv_other_home_signature)
    TextView tvOtherHomeSignature;
    @BindView(R.id.ll_other_home_focus)
    LinearLayout llOtherHomeFocus;
    @BindView(R.id.tv_other_home_focus_count)
    TextView tvOtherHomeFocusCount;
    @BindView(R.id.ll_other_home_fans)
    LinearLayout llOtherHomeFans;
    @BindView(R.id.tv_other_home_fans_count)
    TextView tvOtherHomeFansCount;
    @BindView(R.id.ll_other_home_stars)
    LinearLayout llOtherHomeStars;
    @BindView(R.id.tv_other_home_stars_count)
    TextView tvOtherHomeStarsCount;
    @BindView(R.id.iv_peronsal_share)
    ImageView ivPeronsalShare;
    @BindView(R.id.iv_other_peronsal_share)
    ImageView ivOtherPeronsalShare;

    @BindView(R.id.rl_other_home_header_big)
    RelativeLayout rlOtherHomeHeaderBig;
    @BindView(R.id.iv_other_home_header_big)
    ImageView ivOtherHomeHeaderBig;

    private int rlTopHeight = 0;

    @BindView(R.id.ll_other_home_head)
    View ll_other_home_head;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.top_1)
    RelativeLayout top_1;
    @BindView(R.id.rl_other_home_multi_btn)
    RelativeLayout rl_other_home_multi_btn;
    //    @BindView(R.id.ll_switch)
//    LinearLayout llSwitch;
    RecyclerScrollListener mScrollListener;

    @BindView(R.id.iv_peronsal_set)
    ImageView ivPeronsalSet;
    @BindView(R.id.iv_personal_add)
    ImageView ivPersonalAdd;
    @BindView(R.id.iv_personal_edit)
    ImageView ivPersonalEdit;

    @BindView(R.id.top)
    RelativeLayout top;
    @BindView(R.id.top_bg)
    View topBg;

    private ArrayList<DcBaseFragment> mFraments;
    private PersonalProductFragment personalProductFragment;
    private PersonalLoveFragment personalLoveFragment;
    private MyFragmentPagerAdapter myFragmentPagerAdapter;

    private Intent intent;
    private boolean fromComment;

    long user_id = 0;
    private UserInfo userInfo;
    private List<ReportType> reportTypeList;
    private ShareInfo shareInfo;
    private ShareInfo shareHome;
    private PopupWindow shareWindow;

    private OtherHomePresenter otherHomePresenter;

    public static final String KEY_PARAM = "user_id";

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_home;
    }

    @Override
    protected void initData() {
        super.initData();
        RxBus2.get().register(this);
        otherHomePresenter = new OtherHomePresenter(this);
        addPresenter(otherHomePresenter);
        llOtherHomeProduct.setSelected(true);
        llOtherHomeLove.setSelected(false);

        bindListener();

        intent = getIntent();
        user_id = intent.getLongExtra(KEY_PARAM, 0);
        fromComment = intent.getBooleanExtra("fromComment", false);
        otherHomePresenter.getOtherHomeInfo(user_id);

        if (AccountUtil.getUserId() == user_id) {
            //个人用户
            ivPeronsalSet.setVisibility(View.VISIBLE);
            ivPersonalAdd.setVisibility(View.VISIBLE);
            ivPersonalEdit.setVisibility(View.VISIBLE);
            ivOtherHomeAdd.setVisibility(View.GONE);
            ivPeronsalShare.setVisibility(View.VISIBLE);
        } else {
            //他人用户
            ivOtherHomeMore.setVisibility(View.VISIBLE);
            ivOtherHomeAdd.setVisibility(View.VISIBLE);
            ivOtherPeronsalShare.setVisibility(View.VISIBLE);

            reportTypeList = new ArrayList<>();

            List<ReportType> list = InitCatchData.userReposrtList().getReport_type();
            for (ReportType type : list) {
                if (type.getResource() == 1) {
                    reportTypeList.add(type);
                }
            }
            if (null != reportTypeList && reportTypeList.size() > 0) {

            } else {
                otherHomePresenter.getReportList();
            }
        }

        rlOtherHomeHeaderBig.setVisibility(View.GONE);
        int width = ScreenUtil.getScreenWidth(this);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, width);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
        ivOtherHomeHeaderBig.setLayoutParams(layoutParams);

        int widthS = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        int heightS = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        top_1.measure(widthS, heightS);

        rlTopHeight = top_1.getMeasuredHeight() - DeviceUtils.dip2px(this, 44);
        mScrollListener = this;
        tvName.setAlpha(0);
        topBg.setAlpha(0);
    }

    private void bindListener() {
        ivBack.setOnClickListener(this);
        ivOtherHomeMore.setOnClickListener(this);

        ivOtherHomeHeader.setOnClickListener(this);

        ivOtherHomeAdd.setOnClickListener(this);
        llOtherHomeFocus.setOnClickListener(this);
        llOtherHomeFans.setOnClickListener(this);

        llOtherHomeProduct.setOnClickListener(this);
        llOtherHomeLove.setOnClickListener(this);

        ivPersonalEdit.setOnClickListener(this);
        ivPeronsalSet.setOnClickListener(this);
        ivPersonalAdd.setOnClickListener(this);

        top.setOnClickListener(this);

        ivPeronsalShare.setOnClickListener(this);
        ivOtherPeronsalShare.setOnClickListener(this);
    }

    @Override
    public void handleOtherHomeInfoSucceed(UserInfo userHomeEntry) {
        userInfo = userHomeEntry;

        String cover_url = userHomeEntry.getCover_url();
        if (!TextUtils.isEmpty(cover_url)) {
            GlideLoader.loadCircleImage(cover_url, ivOtherHomeHeader, R.drawable.icon_profile_bg_user_default);
        }

        if (!TextUtils.isEmpty(userHomeEntry.getCover_ori())) {
            GlideLoader.loadImage(userHomeEntry.getCover_ori(), ivOtherHomeHeaderBig, R.drawable.icon_profile_bg_user_default);
        }

        tvOtherHomeName.setText(userHomeEntry.getName());
        tvName.setText(userHomeEntry.getName());
        String location = userInfo.getRegion();
        if (TextUtils.isEmpty(location)) {
            location = getResources().getString(R.string.user_location_fail);
        }
        String constellation = userInfo.getConstellation();
        if (TextUtils.isEmpty(constellation)) {
            constellation = getResources().getString(R.string.user_default_constellation);
        }
        tvOtherHomeInfo.setText(location + "  ·  " + constellation);

        tvPersonalId.setText(getString(R.string.user_id, userInfo.getDc_num()));

        String description = userHomeEntry.getDescription();
        if (!TextUtils.isEmpty(description)) {
            tvOtherHomeSignature.setText(description);
            tvOtherHomeSignature.setVisibility(View.VISIBLE);
        }

        UserHomeRelation userHomeRelation = userHomeEntry.getRelation();
        if (null != userHomeRelation) {
            tvOtherHomeFocusCount.setText(String.valueOf(userHomeRelation.getFollow_count()));
            tvOtherHomeFansCount.setText(String.valueOf(userHomeRelation.getFans_count()));

            if (userHomeRelation.is_follow()) {
                ivOtherHomeFocusState.setImageResource(R.drawable.icon_friend_check_nor);
                tvOtherHomeFocusState.setText(getString(R.string.user_follower));
            }
        } else {
            tvOtherHomeFocusCount.setText("0");
            tvOtherHomeFansCount.setText("0");
        }

        UserHomeData userHomeData = userHomeEntry.getData();
        if (null != userHomeData) {
            tvOtherHomeStarsCount.setText(String.valueOf(userHomeData.getLike()));
        } else {
            tvOtherHomeStarsCount.setText("0");
        }

        tvOtherHomeProductCount.setText("作品(" + String.valueOf(userHomeData.getOpus_count()) + ")");
        tvOtherHomeLoveCount.setText("喜欢(" + String.valueOf(userHomeData.getLike_opus_count()) + ")");

        shareInfo = userHomeEntry.getShare_info();
        shareHome = userHomeEntry.getShare_home();

        initViewPage();
    }

    private void initViewPage() {
        mFraments = new ArrayList<>();

        Bundle bundle = new Bundle();
        bundle.putLong("user_id", userInfo.getId());
        bundle.putInt("headHeight", rlTopHeight);
        bundle.putBoolean("lazy_mode", false);
        bundle.putBoolean("isShowPop", false);
        personalProductFragment = PersonalProductFragment.newInstance();
        personalProductFragment.getmScrollListener(mScrollListener);
        personalProductFragment.setArguments(bundle);

        bundle = new Bundle();
        bundle.putLong("user_id", userInfo.getId());
        bundle.putInt("headHeight", rlTopHeight);
        bundle.putBoolean("lazy_mode", true);
        personalLoveFragment = PersonalLoveFragment.newInstance();
        personalLoveFragment.getmScrollListener(mScrollListener);
        personalLoveFragment.setArguments(bundle);

        mFraments.add(personalProductFragment);
        mFraments.add(personalLoveFragment);
        myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), mFraments);
        vpOtherHomeFragments.setAdapter(myFragmentPagerAdapter);
        vpOtherHomeFragments.setOffscreenPageLimit(2);
        vpOtherHomeFragments.setOnPageChangeListener(this);
    }

    @Override
    public void handleOtherHomeInfoFailure(String error_msg) {
        ToastUtil.showToast(error_msg);
    }

    @Override
    public void handleReportListSucceed(ReportTypeResponse response) {
        reportTypeList = response.getReport_type_list();
    }

    @Override
    public void handleReportListFailure(String error_msg) {
        ToastUtil.showToast(error_msg);
    }

    @Override
    public void handleReportSucceed() {
        ToastUtil.showToast(R.string.user_report_suc);
        if (null != popReportContentActionSheet) {
            popReportContentActionSheet.dismiss();
        }
    }

    @Override
    public void handleReportFailure(String error_msg) {
        ToastUtil.showToast(error_msg);
        if (null != popReportContentActionSheet) {
            popReportContentActionSheet.dismiss();
        }
    }

    @Override
    public void handleFocusSucceed(boolean isFollower, int resStrId) {
        if (isFollower) {
            ivOtherHomeFocusState.setImageResource(R.drawable.icon_friend_check_nor);
            tvOtherHomeFocusState.setText(getString(R.string.user_follower));

            userInfo.getRelation().setIs_follow(true);
        } else {
            ivOtherHomeFocusState.setImageResource(R.drawable.icon_profile_other_add);
            tvOtherHomeFocusState.setText(getString(R.string.user_focus_normal));
            userInfo.getRelation().setIs_follow(false);
        }
        ToastUtil.showToast(resStrId);
    }

    @Override
    public void handleFocusFailure(String error_msg) {
        ToastUtil.showToast(error_msg);
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        int currentItem = vpOtherHomeFragments.getCurrentItem();
        if (positionOffsetPixels > 0) {
            SparseArrayCompat<RecyclerScrollListener> scrollTabHolders = myFragmentPagerAdapter.getScrollTabHolders();
            RecyclerScrollListener fragmentContent;
            if (position < currentItem) {
                fragmentContent = scrollTabHolders.valueAt(position);
            } else {
                fragmentContent = scrollTabHolders.valueAt(position + 1);
            }
            fragmentContent.adjustScroll((int) (rlTopHeight + top_1.getTranslationY()), rlTopHeight);
        }
    }

    @Override
    public void onPageSelected(int position) {
        SparseArrayCompat<RecyclerScrollListener> scrollTabHolders = myFragmentPagerAdapter.getScrollTabHolders();

        if (scrollTabHolders == null || scrollTabHolders.size() != mFraments.size()) {
            return;
        }
        top_1.setTranslationY(0);
        ll_other_home_head.setAlpha(1);
        top_1.invalidate();

        if (position == 0) {
            llOtherHomeProduct.setSelected(true);
            llOtherHomeLove.setSelected(false);
        } else if (position == 1) {
            llOtherHomeProduct.setSelected(false);
            llOtherHomeLove.setSelected(true);
        }
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    private PopActionSheetNoTitle popReportActionSheet;
    private PopReportContentActionSheet popReportContentActionSheet;
    private CustomDialog customDialog;

    @Override
    protected void onSingleClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.iv_other_home_more:
                if (!AccountUtil.isLogin()) {
                    showReLogin();
                    return;
                }
                if (null != reportTypeList && reportTypeList.size() > 0) {
                    popReportActionSheet = new PopActionSheetNoTitle(this);
                    popReportActionSheet.setOnSnsClickListener(new PopActionSheetNoTitle.OnSnsClickListener() {
                        @Override
                        public void onSnsClick() {
                            popReportContentActionSheet = new PopReportContentActionSheet(PersonalHomeActivity.this);
                            popReportContentActionSheet.setReportTypeList(reportTypeList);
                            popReportContentActionSheet.setOnSnsClickListener(new PopReportContentActionSheet.OnSnsClickListener() {
                                @Override
                                public void onSnsClick(ReportType reportType) {
                                    if (null != reportType) {
                                        if (null != userInfo) {
                                            otherHomePresenter.reportUser(userInfo.getId(), reportType.getId());
                                        }
                                    }
                                }
                            });
                            popReportContentActionSheet.show();
                        }
                    });
                    popReportActionSheet.show();
                }
                break;
            case R.id.iv_other_home_header:
            case R.id.iv_personal_edit:
                if (AccountUtil.getUserId() == user_id) {
                    if (null != userInfo) {
                        Navigator.getInstance().navigateToUserInfo(this, userInfo);
                    }
                } else {
                    rlOtherHomeHeaderBig.setVisibility(View.VISIBLE);
                    rlOtherHomeHeaderBig.setOnTouchListener(new View.OnTouchListener() {
                        @Override
                        public boolean onTouch(View v, MotionEvent event) {
                            if (event.getAction() == MotionEvent.ACTION_UP) {
                                rlOtherHomeHeaderBig.setVisibility(View.GONE);
                            }
                            return true;
                        }
                    });
                }
                break;
            case R.id.ll_other_home_add:
                if (!AccountUtil.isLogin()) {
                    showReLogin();
                    return;
                }
                if (null != userInfo) {
                    UserHomeRelation relation = userInfo.getRelation();
                    if (null != relation) {
                        final boolean isFollow = relation.is_follow();
                        if (isFollow) {
                            customDialog = new CustomDialog(this, R.style.BaseDialogTheme);
                            customDialog.setTitle(getString(R.string.dialog_focus_tip));
                            customDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    customDialog.dismiss();
                                    otherHomePresenter.updateFocusState(isFollow, userInfo.getId());
                                }
                            });
                            customDialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    customDialog.dismiss();
                                }
                            });
                            customDialog.show();
                        } else {
                            otherHomePresenter.updateFocusState(isFollow, userInfo.getId());
                        }
                    }
                }
                break;
            case R.id.ll_other_home_focus:
                if (null != userInfo) {
                    UserInfo u = new UserInfo();
                    u.setId(userInfo.getId());
                    u.setName(userInfo.getName());
                    Navigator.getInstance().navigateToFocus(this, u);
                }
                break;
            case R.id.ll_other_home_fans:
                if (null != userInfo) {
                    UserInfo u = new UserInfo();
                    u.setId(userInfo.getId());
                    u.setName(userInfo.getName());
                    Navigator.getInstance().navigateToFans(this, u);
                }
                break;
            case R.id.ll_other_home_product:
                llOtherHomeProduct.setSelected(true);
                llOtherHomeLove.setSelected(false);
                vpOtherHomeFragments.setCurrentItem(0);
                break;
            case R.id.ll_other_home_love:
                llOtherHomeProduct.setSelected(false);
                llOtherHomeLove.setSelected(true);
                vpOtherHomeFragments.setCurrentItem(1);
                break;
            case R.id.iv_peronsal_set:
                Intent intent = new Intent(this, SettingActivity.class);
                startActivity(intent);
                break;
            case R.id.iv_personal_add:
                Navigator.getInstance().navigateToAddFriend(this, shareInfo);
                break;
            case R.id.iv_peronsal_share:
            case R.id.iv_other_peronsal_share:
                shareWindow = PopupWindowUtils.showNormal(this, vpOtherHomeFragments, shareClick);
                break;
            default:
                break;
        }
    }

    public static Intent getCallingIntent(Context context, boolean fromComment, long user_id) {
        Intent intent = new Intent(context, PersonalHomeActivity.class);
        intent.putExtra(KEY_PARAM, user_id);
        intent.putExtra("fromComment", fromComment);
        return intent;
    }

    @Override
    public void Scrolled(int distance, int pagePosition) {
//        if (distance >= rlTopHeight) {
//            return;
//        }
        float maxDis = -rlTopHeight + DeviceUtils.dip2px(this, 15);
        float translationY = Math.max(-distance, maxDis);
        top_1.setTranslationY(translationY);

        float percent = Math.abs(translationY) / (float) Math.abs(rlTopHeight);
        float falpha = 1 - percent;
        ll_other_home_head.setAlpha(falpha);

//        tv_user_name_bar.setTranslationY(-translationY / 3);
        int tvPersonalNameTop = DensityUtils.dip2px(this, 60);
//        int tvPersonalNameHeight = tvName.getHeight();
        if (distance > tvPersonalNameTop) {
            float namePercent = Math.abs(translationY) / (float) Math.abs(rlTopHeight - tvPersonalNameTop);
            tvName.setAlpha(namePercent);
            topBg.setAlpha(namePercent);
            rl_other_home_multi_btn.setAlpha(1 - namePercent);
        } else {
            tvName.setAlpha(0);
            topBg.setAlpha(0);
            rl_other_home_multi_btn.setAlpha(1);
        }
    }

    @Override
    public void adjustScroll(int scrollHeight, int headerHeight) {

    }

    private MyClickListener shareClick = new MyClickListener() {
        @Override
        protected void onMyClick(View v) {
            switch (v.getId()) {
                case R.id.llWeChat:
                    loading();
                    ShareSdkUtils.getInstance().showWechatShare(PersonalHomeActivity.this, shareHome, PersonalHomeActivity.this);
                    break;
                case R.id.llCircle:
                    loading();
                    ShareSdkUtils.getInstance().showWechatMomentsShare(PersonalHomeActivity.this, shareHome, PersonalHomeActivity.this);
                    break;
                case R.id.llWeibo:
                    loading();
                    ShareSdkUtils.getInstance().showWeiboShare(PersonalHomeActivity.this, shareHome, PersonalHomeActivity.this);
                    break;
                case R.id.llQQ:
                    loading();
                    ShareSdkUtils.getInstance().showQQShare(PersonalHomeActivity.this, shareHome, PersonalHomeActivity.this);
                    break;
                case R.id.llCopy:
                    ClipboardManager cmb = (ClipboardManager) PersonalHomeActivity.this.getSystemService(Context.CLIPBOARD_SERVICE);
                    cmb.setPrimaryClip(ClipData.newPlainText(null, shareHome.getShare_url()));
                    showToast(R.string.copy_succeed);
                    break;
            }
            if (null != shareWindow && shareWindow.isShowing()) {
                shareWindow.dismiss();
            }
        }
    };

    @Override
    public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
        dismissLoad();
        ToastUtil.showToast(R.string.share_suc);
    }

    @Override
    public void onError(Platform platform, int i, Throwable throwable) {
        dismissLoad();
        ToastUtil.showToast(R.string.share_faid);
    }

    @Override
    public void onCancel(Platform platform, int i) {
        dismissLoad();
        ToastUtil.showToast(R.string.share_cancel);
    }
}
